<?php
	namespace Qzn\Controller;
	
	require_once('./View/friendListView.php');
	require_once('./Model/friendListHandler.php');
	
	class FriendListController {
		
		/**
		 * @return string $html
		 * @param $dataBase
		 * @param $loginView
		 */
		public function DoControll(\Qzn\Model\Database $db, \Qzn\Model\LoginHandler $lh, \Qzn\View\LoginView $lw, \Qzn\Model\ProfileHandler $ph) {
			$flw = new \Qzn\View\FriendListView();
			$flh = new \Qzn\Model\FriendListHandler($db);
			$html = "";
			
			if ($lh->IsLoggedIn()) {		
				if ($flw->TriedToRemoveFriend()) {
					$html .= $flh->RemoveFriend($flw, $lw);
				}
				
				if ($flw->TriedToBlockFriend()) {
					$html .= $flh->BlockFriend($flw, $lw);
				}

				if ($flw->TriedToAcceptFriend()) {
					$html .= $flh->AcceptFriend($flw, $lw);
				}
				
				if ($flw->TriedToUnblockFriend()) {
					$html .= $flh->UnblockFriend($flw, $lw);
				}
				
				$html .= $flw->DoFriendList($flh, $lw, $ph);
			}
			
			return $html;
		}
	}
?>